package com.mdp.sms.ctrl;

import java.util.*;
import java.util.stream.Collectors;

import com.mdp.sms.entity.SmsFlow;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.*;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mdp.core.entity.Result;
import com.mdp.core.query.QueryTools;
import static com.mdp.core.utils.BaseUtils.*;
import com.mdp.core.entity.Tips;
import com.mdp.core.entity.LangTips;
import com.mdp.core.err.BizException;
import com.mdp.core.utils.RequestUtils;
import com.mdp.core.utils.NumberUtil;
import com.mdp.safe.client.entity.User;
import com.mdp.safe.client.utils.LoginUtils;
import com.mdp.swagger.ApiEntityParams;
import io.swagger.annotations.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.http.HttpServletRequest;

import com.mdp.sms.service.SmsSignService;
import com.mdp.sms.entity.SmsSign;
/**
 * @author maimeng-mdp code-gen
 * @since 2024-3-6
 */
@RestController
@RequestMapping(value="/**/sms/smsSign")
@Api(tags={"短信签名-操作接口"})
public class SmsSignController {
	
	static Logger logger =LoggerFactory.getLogger(SmsSignController.class);
	
	@Autowired
	private SmsSignService smsSignService;

	@ApiOperation( value = "短信签名-查询列表",notes=" ")
	@ApiEntityParams(SmsSign.class)
	@ApiResponses({
		@ApiResponse(code = 200,response=SmsSign.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'错误码'},total:总记录数,data:[数据对象1,数据对象2,...]}")
	})
	@RequestMapping(value="/list",method=RequestMethod.GET)
	public Result listSmsSign(@ApiIgnore @RequestParam Map<String,Object> params){
			User user=LoginUtils.getCurrentUserInfo();
			QueryWrapper<SmsSign> qw = QueryTools.initQueryWrapper(SmsSign.class , params);
			IPage page=QueryTools.initPage(params);
			List<Map<String,Object>> datas = smsSignService.selectListMapByWhere(page,qw,params);
			return Result.ok("query-ok","查询成功").setData(datas).setTotal(page.getTotal());
	}
	/**
	 * 群发短信
	 * @author lyk
	 * @cdate 2019/9/18 10:50
	 */
	@RequestMapping(value = "/groupSendSms", method = RequestMethod.POST)
	public Result  groupSendSms(@RequestBody Map<String, Object> params) {
		List<SmsFlow>  result=smsSignService.groupSendSms(params);
		return Result.ok().setData(result);
	}

	/**
	 * 短信回复
	 * @author lyk
	 * @cdate 2019/9/18 10:50
	 */
	@RequestMapping(value = "/smsReply", method = RequestMethod.POST)
	public Result   smsReply(@RequestBody Map<String, Object> params) {
			smsSignService.smsReply(params);
		return Result.ok();
	}

}
